package com.ssy.lingxi.settle.accounts.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 发票种类
 * @author 伍将
 * @date 2020/10/21
 * @version 2.0.0
 */
public enum InvoiceKindEnum {

    /**
     * 所有
     */
    ALL(0, "所有"),
    /**
     * 增值税普通发票（默认）
     */
    COMMON(1, "增值税普通发票"),
    /**
     * 增值税专用发票
     */
    SPECIAL(2, "增值税专用发票");

    private final Integer code;
    private final String message;

    InvoiceKindEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    public static String getMessage(Integer code) {
        return Arrays.stream(InvoiceKindEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(ALL).getMessage();
    }
}
